<template>
  <div class="sys-monitor" :style="siteContentViewHeight">
    <div class="monitor-menu">
      <ul>
        <li
          v-for="item in menuList"
          :key="item.name"
          :class="{ active: selectMenu.name === item.name }"
          @click="selectMenu = item"
        >
          <icon-svg :name="item.icon" :class="{ 'rule-icon': item.name === 'rule' }"></icon-svg>{{ item.label }}
        </li>
      </ul>
    </div>
    <div class="monitor-content tag-scrollbar">
      <transition name="el-fade-in-linear">
        <div>
          <div class="monitor-content-title">
            <span class="title-icon">
              <icon-svg :name="selectMenu.icon" :class="{ 'rule-icon': selectMenu.name === 'rule' }"></icon-svg>
            </span>
            {{ selectMenu.label }}
          </div>
          <monitor-quality v-if="selectMenu.name === 'quality'" ref="monitor-quality"></monitor-quality>
          <monitor-abnorm v-if="selectMenu.name === 'abnorm'" ref="monitor-abnorm"></monitor-abnorm>
          <monitor-deploy v-if="selectMenu.name === 'deploy'" ref="monitor-deploy"></monitor-deploy>
          <monitor-task v-if="selectMenu.name === 'task'" ref="monitor-task"></monitor-task>
          <monitor-rule v-if="selectMenu.name === 'rule'" ref="monitor-rule"></monitor-rule>
        </div>
      </transition>
    </div>
  </div>
</template>

<script>
import monitorQuality from './quality/monitor-quality'
import monitorAbnorm from './abnorm/monitor-abnorm'
import monitorDeploy from './monitor-deploy'
import monitorTask from './task/monitor-task'
import monitorRule from './rule/monitor-rule'
export default {
  components: {
    monitorQuality,
    monitorAbnorm,
    monitorDeploy,
    monitorTask,
    monitorRule
  },
  data() {
    return {
      menuList: [
        { label: '标签质量看板', name: 'quality', icon: 'iconQuality' },
        { label: '异常预警', name: 'abnorm', icon: 'iconAbnorm' },
        { label: '预警配置', name: 'deploy', icon: 'iconSetting' },
        { label: '规则预警', name: 'rule', icon: 'iconDeploy' },
        { label: '任务与历史', name: 'task', icon: 'iconClock' }
        // { label: '效能反馈录入', name: 'effect' }
      ],
      selectMenu: {}
    }
  },
  computed: {
    documentClientHeight: {
      get() {
        return this.$store.state.common.documentClientHeight
      }
    },
    siteContentViewHeight() {
      return { height: this.documentClientHeight - 90 + 'px' }
    }
  },
  watch: {
    selectMenu(val) {
      this.$nextTick(() => {
        this.$refs['monitor-' + val.name].getDetail()
      })
    }
  },
  created() {
    this.selectMenu = this.menuList[0]
  },
  methods: {}
}
</script>

<style lang="scss">
.sys-monitor {
  display: flex;
  overflow: hidden;
  .monitor-menu {
    width: 280px;
    height: 100%;
    padding: 20px;
    border-right: 1px solid #eee;
    background-color: #fff;
    li {
      padding: 0 20px 0 40px;
      line-height: 40px;
      border-radius: 3px;
      cursor: pointer;
      &.active {
        font-size: 16px;
        font-weight: bold;
        color: #fff;
        background-color: #4d81ea;
      }
      svg {
        width: 20px;
        height: 20px;
        margin: -5px 5px 0 0;
        vertical-align: middle;
      }
      .rule-icon {
        width: 17px;
        height: 17px;
        margin-right: 8px;
      }
    }
  }
  .monitor-content {
    flex: 1;
    height: 100%;
    padding: 10px 10px 10px 30px;
    overflow: auto;
    .monitor-content-title {
      font-size: 17px;
      margin-bottom: 10px;
      .title-icon {
        display: inline-block;
        width: 30px;
        height: 30px;
        margin: -4px 10px 0 0;
        line-height: 30px;
        text-align: center;
        color: #fff;
        background-color: #54c6e2;
        vertical-align: middle;
        border-radius: 50%;
      }
      svg {
        width: 20px;
        height: 20px;
        margin-top: 5px;
      }
      .rule-icon {
        width: 17px;
        height: 17px;
      }
    }
  }
}
</style>
